package com.huitone.gddw.service.impl.monitoring.base;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.huitone.gddw.dao.entity.WarnRecv;
import com.huitone.gddw.dao.monitoring.IWarnRecvDao;
import com.huitone.gddw.service.dto.monitoring.base.WarnRecvDTO;
import com.huitone.gddw.service.monitoring.base.IWarnRecvService;
import com.huitone.gddw.utils.SysLoginUtil;

/**
 * 预警接收人管理  接口实现类
 * @author wuluodan
 *
 */
@Service
public class WarnRecvService implements IWarnRecvService {

	@Autowired
	private IWarnRecvDao warnRecvDao;
	
	@Override
	public void delByObjId(String objId) {
		warnRecvDao.delByObjId(objId);
	}

	@Override
	public List<WarnRecvDTO> select(Map<String, Object> params) {
		return warnRecvDao.select(params);
	}
	
	@Override
	public List<WarnRecv> getByObjId(String objId) {
		return warnRecvDao.getByObjId(objId);
	}

	@Override
	public WarnRecv getById(String recId) {
		return warnRecvDao.getById(recId);
	}

	@Override
	public void save(List<WarnRecv> listSave, List<WarnRecv> listUpdate, List<WarnRecv> listDel) {
		String userId = SysLoginUtil.getLoginUserId();
		if (listSave != null && listSave.size() > 0) {
			for (WarnRecv warnRecv : listSave) {
				warnRecv.setInsertStaffId(userId);
				warnRecv.setInsertTime(new Date());
				warnRecv.setLastModStaffId(userId);
				warnRecv.setLastModTime(new Date());
			}
			warnRecvDao.saveBatch(listSave);
		}
		if (listUpdate != null && listUpdate.size() > 0) {
			for (WarnRecv warnRecv : listUpdate) {
				warnRecv.setLastModStaffId(userId);
				warnRecv.setLastModTime(new Date());
			}
			warnRecvDao.updateBatch(listUpdate);
		}
		if (listDel != null && listDel.size() > 0) {
			warnRecvDao.deleteBatch(listDel);
		}
	}

}
